var clixpy_domain = "clixpy.com";
var clixpy_user_id = "4820";
var clixpy_sess_id = "df0221d52addbc4ba747f5692e867027";
var clixpy_recv_subdmn = "";

var Clixpy = function() {
	this.w = window;
	this.d = document;
	this.nav = null;
	this.error = false;
	this.protocol = null;
	this.impression = null;
	this.start_time = 0;
	this.loaded_time = 0;
	this.html = null;
	this.base_target = null;
	this.base_href = null;
	this.encoding = null;
	this.logdata = [];
	this.flash = null;
	this.body_loaded = false;
	this.idle_timeout = false;
	this.last_event = null;
	this.intervals = {};
	this.domain = clixpy_domain;
	this.user_id = clixpy_user_id;
	this.sess_id = clixpy_sess_id;
	this.recv_subdmn = clixpy_recv_subdmn
};

Clixpy.prototype.INIT = function() {
	if (this.w.clixpy_disabled) {
		return
	}
	this.start_time = this.get_time();
	this.nav = navigator.userAgent.toLowerCase();
	if (this.w.clixpy_disable_msie6 == true && this.nav.indexOf('msie 6') != -1) {
		return
	}
	this.protocol = this.d.location.protocol == "https:" ? "https://"
			: "http://";
	var e = this;
	var f = function() {
		if (!e.html) {
			e.html = e.d.documentElement.innerHTML.toString()
		}
	};
	var g = function() {
		if (!e.body_loaded) {
			e.init_step2()
		}
	};
	var h = this.w.onload;
	if (typeof h != 'function') {
		this.w.onload = function() {
			f();
			g()
		}
	} else {
		this.w.onload = function() {
			f();
			h();
			g()
		}
	}
	this.attach_event(this.w, 'load', function() {
		f();
		g()
	});
	setTimeout( function() {
		f();
		g()
	}, 3000);
	this.w.onerror = function(a, b, c, d) {
		return true
	}
};
Clixpy.prototype.init_step2 = function() {
	this.body_loaded = true;
	this.loaded_time = this.get_time();
	if (this.error) {
		return false
	}
	if (!this.d.body || !this.get_screen_size() || !this.get_screen_scroll()) {
		this.error = true;
		return false
	}
	if (!this.html) {
		this.error = true;
		return false
	}
	this.encoding = this.d.charset ? this.d.charset
			: (this.d.characterSet ? this.d.characterSet
					: (this.d.inputEncoding ? this.d.inputEncoding : ""));
	this.impression = this.get_time() + "i"
			+ Math.round(Math.random() * 10000000);
	var a = this;
	var b = "clixpy_swf";
	if (this.protocol == "https://") {
		var c = "https://" + this.domain + "/clixpy.swf?r="
				+ Math.round(Math.random() * 10000);
		var d = "https://" + this.domain + "/clixpy_receiver.php?info="
				+ this.user_id + "--" + this.sess_id + "--" + this.impression
				+ "--" + this.w.location.href
	} else {
		var c = "http://" + this.recv_subdmn + this.domain + "/clixpy.swf?r="
				+ Math.round(Math.random() * 10000);
		var d = "http://" + this.recv_subdmn + this.domain
				+ "/clixpy_receiver.php?info=" + this.user_id + "--"
				+ this.sess_id + "--" + this.impression + "--"
				+ this.w.location.href
	}
	var e = '';
	e += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1" height="1" id="' + b + '">';
	e += '<param name=movie value="' + c + '" />';
	e += '<param name="allowScriptAccess" value="always" />';
	e += '<param name="flashvars" value="submiturl=' + d + '" />';
	e += '<embed src="'
			+ c
			+ '" width="1" height="1" name="'
			+ b
			+ '" allowScriptAccess="always" flashvars="submiturl='
			+ d
			+ '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	e += '</object>';
	var f = this.d.createElement("IFRAME");
	f.name = "clixpy_ifrm";
	f.id = "clixpy_ifrm";
	f.width = "0";
	f.height = "0";
	f.border = "0";
	f.frameBorder = "0";
	f.style.position = "absolute";
	f.style.left = "-10000px";
	f.style.top = "-10000px";
	this.d.body.appendChild(f);
	var g = f.contentDocument;
	if (g === undefined || g === null) {
		g = f.contentWindow.document
	}
	g.open();
	g.close();
	g.body.innerHTML = e;
	f.contentWindow.clixpy_obj = this;
	var h = function() {
		if (!a.flash) {
			a.flash = g[b]
		}
		if (!a.flash || !a.flash.jsfunc) {
			setTimeout( function() {
				h()
			}, 300);
			return false
		}
		a.init_step3()
	};
	h()
};
Clixpy.prototype.init_step3 = function() {
	var c, i, obj = this;
	this.attach_event(this.d, 'click', function(a) {
		a = obj.get_event(a);
		if (a && a.clientX) {
			obj.write_log("CL", [ a.clientX, a.clientY ])
		}
	});
	this.attach_event(this.d, 'mousemove', function(a) {
		if (Math.round(Math.random() * 1000) < 667) {
			a = obj.get_event(a);
			if (a && a.clientX) {
				obj.write_log("MV", [ a.clientX, a.clientY ])
			}
		}
	});
	this.attach_event(this.w, 'scroll', function(a) {
		obj.write_log("SC", obj.get_screen_scroll())
	});
	this.base_target = "";
	this.base_href = "";
	var b = this.d.getElementsByTagName("BASE");
	for (i = 0; i < b.length; i++) {
		c = b[i].getAttribute("target");
		if (c) {
			this.base_target = c
		}
		c = b[i].getAttribute("href");
		if (c) {
			this.base_href = c
		}
	}
	var d = "URL:" + this.w.location.href + "\n";
	d += "BROWSER:" + navigator.userAgent + "\n";
	d += "SCREEN:" + screen.width + "x" + screen.height + "\n";
	d += "WINDOW:" + this.get_screen_size().join("x") + "\n";
	d += "LCTIME:" + this.start_time + "\n";
	d += "ENCODING:" + this.encoding + "\n";
	d += "BASETARGET:" + this.base_target + "\n";
	d += "BASEHREF:" + this.base_href + "\n";
	d += "PAGELOAD:" + (this.loaded_time - this.start_time) + "\n";
	c = this.get_cookie("ClixpyLastImpr");
	if (c && c !== "") {
		d += "PREVIMPR:" + escape(c) + "\n";
		this.set_cookie("ClixpyLastImpr", "", "." + this.get_current_domain())
	}
	d += "COOKIES:" + this.d.cookie + "\n";
	d += "HTML:\n" + this.html;
	this.do_send_data(d);
	var j = 0, el, n, els = this.d.body.getElementsByTagName("*");
	if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
		var e = els.length;
		var f = function(a) {
			for (i = 0; i < 50; i++) {
				if (!els[a] && a >= e - 1) {
					return
				}
				if (els[a]) {
					el = els[a];
					n = el.nodeName;
					if (!(!n || n == "SCRIPT" || n == "STYLE" || n == "TBODY"
							|| n.charAt(0) == "#" || n.charAt(0) == "!")) {
						j++;
						if (!el.id || el.id === "") {
							el.id = "clixpy_id_" + j
						}
						obj.elem_attach_events(el)
					}
				}
				a++
			}
			setTimeout( function() {
				f(a)
			}, 1)
		};
		f(0)
	} else {
		for (i = 0; i < els.length; i++) {
			el = els[i];
			n = el.nodeName;
			if (!n || n == "SCRIPT" || n == "STYLE" || n == "TBODY"
					|| n.charAt(0) == "#" || n.charAt(0) == "!") {
				continue
			}
			j++;
			if (!el.id || el.id === "") {
				el.id = "clixpy_id_" + j
			}
			this.elem_attach_events(el)
		}
	}
	setInterval( function() {
		obj.send_report()
	}, 3000)
};
Clixpy.prototype.elem_attach_events = function(e) {
	if (e.getAttribute("noclixpy")) {
		return
	}
	var f, obj = this, tag = e.nodeName;
	if (this.get_func_code(e.onmouseover) !== "") {
		this.attach_event(e, 'mouseover', function(a) {
			obj.write_log("OMO", [ obj.get_event_target(this, a).id ])
		})
	}
	if (this.get_func_code(e.onmouseout) !== "") {
		this.attach_event(e, 'mouseout', function(a) {
			obj.write_log("OMOU", [ obj.get_event_target(this, a).id ])
		})
	}
	this.attach_event(e, 'mousedown', function(a) {
		obj.write_log("OMDN", [ obj.get_event_target(this, a).id ])
	});
	this.attach_event(e, 'mouseup', function(a) {
		obj.write_log("OMUP", [ obj.get_event_target(this, a).id ])
	});
	var g = false;
	if (tag == "A") {
		if (!e.href || e.href === "" || e.href.charAt(0) == "#"
				|| e.target == "_blank" || e.href.match(/^javascript/)) {
			this.attach_event(e, 'click', function(a) {
				obj.write_log("OCL", [ obj.get_event_target(this, a).id ])
			});
			g = true
		} else {
			this.attach_event(e, 'click', function(a) {
				a = obj.get_event(a);
				if (a && a.clientX) {
					obj.write_log("CL", [ a.clientX, a.clientY ])
				}
				obj.write_log("OCL", [ obj.get_event_target(this, a).id ]);
				obj.force_send_data()
			});
			g = true
		}
	} else if (tag == "INPUT" && (e.type == "checkbox" || e.type == "radio")) {
		this.attach_event(e, 'click', function(a) {
			obj.write_log("CHBX", [ obj.get_event_target(this, a).id,
					obj.get_event_target(this, a).checked ? 1 : 0 ])
		});
		g = true
	}
	if (tag == "SELECT") {
		this.attach_event(e, 'change', function(a) {
			obj.write_log("SCH", [ obj.get_event_target(this, a).id,
					obj.get_event_target(this, a).selectedIndex ])
		})
	}
	if (tag == "TEXTAREA" || (tag == "INPUT" && e.type == "text")) {
		this.intervals["txt---" + e.id] = false;
		var h = this.intervals["txt---" + e.id];
		this.attach_event(e, 'focus', function(a) {
			var b = obj.get_event_target(this, a);
			clearInterval(h);
			h = setInterval( function() {
				if (b.value !== undefined) {
					obj.write_log("TXT", [ b.id, escape(b.value) ])
				}
			}, 2123);
			setTimeout( function() {
				if (b.value !== undefined) {
					obj.write_log("TXT", [ b.id, escape(b.value) ])
				}
			}, 500)
		});
		this.attach_event(e, 'blur', function(a) {
			var b = obj.get_event_target(this, a);
			clearInterval(h);
			if (b.value !== undefined) {
				obj.write_log("TXT", [ b.id, escape(b.value) ])
			}
		});
		this.attach_event(e, 'mouseup', function(a) {
			var b = obj.get_event_target(this, a);
			clearInterval(h);
			h = setInterval( function() {
				if (b.value !== undefined) {
					obj.write_log("TXT", [ b.id, escape(b.value) ])
				}
			}, 2123);
			if (b.value !== undefined) {
				obj.write_log("TXT", [ b.id, escape(b.value) ])
			}
		});
		this.attach_event(e, 'keypress', function(a) {
			a = obj.get_event(a);
			if (a && (a.keyCode || a.charCode) && !a.ctrlKey && !a.altKey) {
				var b = obj.get_event_target(this, a);
				if (b.selectionStart !== undefined
						&& b.selectionStart == b.value.length) {
					var c = a.charCode ? a.charCode : a.keyCode;
					if ((c >= 32 && c <= 126) || (c >= 1040 && c <= 1103)
							|| (c == 13 && b.nodeName == "textarea")) {
						var d = b.value.charAt(b.value.length - 1);
						if (d) {
							obj.write_log("TXTK", [ b.id, escape(d) ])
						}
					} else if (c == 8 || c == 13 || c == 127) {
						if (b.value !== undefined) {
							obj.write_log("TXT", [ b.id, escape(b.value) ])
						}
					}
				} else if (Math.round(Math.random() * 1000) < 334) {
					if (b.value !== undefined) {
						obj.write_log("TXT", [ b.id, escape(b.value) ])
					}
				}
				clearInterval(h);
				h = setInterval( function() {
					if (b.value !== undefined) {
						obj.write_log("TXT", [ b.id, escape(b.value) ])
					}
				}, 2123)
			}
		})
	} else if (tag == "INPUT") {
		this.attach_event(e, 'focus', function() {
			obj.write_log("FC", [ e.id ])
		});
		this.attach_event(e, 'blur', function() {
			obj.write_log("BL", [ e.id ])
		})
	}
	if (tag == "FORM") {
		this.attach_event(e, 'submit', function() {
			obj.force_send_data()
		})
	}
	if (!g) {
		this.attach_event(e, 'click', function(a) {
			obj.write_log("OCL", [ obj.get_event_target(this, a).id ])
		})
	}
	return e
};
Clixpy.prototype.send_report = function() {
	if (this.error) {
		return false
	}
	if (this.logdata.length === 0) {
		return true
	}
	var a = this.logdata.slice();
	this.logdata = [];
	var i, data = "LOG:\n";
	for (i = 0; i < a.length; i++) {
		data += a[i][0] + "\t" + a[i][1] + "\t" + a[i][2].join(" ") + "\n"
	}
	this.do_send_data(data);
	if (this.idle_timeout) {
		clearTimeout(this.idle_timeout);
		this.idle_timeout = false
	}
	var b = this;
	this.idle_timeout = setTimeout( function() {
		b.write_log("IDL", [ 6 ])
	}, 6000)
};
Clixpy.prototype.do_send_data = function(a) {
	if (this.error) {
		return false
	}
	if (this.inprogress) {
		return false
	}
	this.inprogress = true;
	this.flash.jsfunc(a);
	var b = this
};
Clixpy.prototype.receive_response = function() {
	this.inprogress = false
};
Clixpy.prototype.write_log = function(a, b) {
	if (this.error) {
		return false
	}
	if (this.logdata.length > 1) {
		var c = this.logdata[this.logdata.length - 1];
		if (c[1] == a && c[2].toString() == b.toString()) {
			return true
		}
	}
	this.logdata[this.logdata.length] = [ this.get_time() - this.start_time, a,
			b ]
};
Clixpy.prototype.force_send_data = function() {
	if (this.error) {
		return false
	}
	if (this.logdata.length > 0) {
		var a = "";
		var b = "";
		var c = this.logdata.reverse();
		for ( var i = 0; i < c.length; i++) {
			if (c[i][1] != "CL" && c[i][1] != "OCL" && c[i][1] != "MV"
					&& c[i][1] != "SC") {
				continue
			}
			b = c[i][0] + "-" + c[i][1] + "-" + c[i][2].join(",") + "|";
			if (a.length + b.length >= 3900) {
				break
			}
			a += b
		}
		if (a === "") {
			return
		}
		this.set_cookie("ClixpyLastImpr", a, "." + this.get_current_domain())
	}
	this.inprogress = false;
	this.send_report()
};
Clixpy.prototype.attach_event = function(b, c, d) {
	if (!b) {
		return false
	}
	if (b.addEventListener) {
		b.addEventListener(c, d, false)
	} else if (b.attachEvent) {
		b.attachEvent('on' + c, d)
	} else {
		var e = this.get_func_code(b['on' + c]);
		var f = this;
		b['on' + c] = function(a) {
			a = f.get_event(a);
			if (e !== "") {
				if (a) {
					f.last_event = a
				}
				f.exec_function(e, this)
			}
		}
	}
};
Clixpy.prototype.get_event_target = function(a, b) {
	if (a != this.w) {
		return a
	}
	var c = this.get_event(b);
	var d = c.target ? c.target : c.srcElement;
	return d
};
Clixpy.prototype.get_func_code = function(a) {
	var b = "";
	if (a === undefined || a === null) {
		return ""
	}
	b = this.trim(a.toString());
	var c = b.indexOf("{");
	if (c != -1) {
		b = this.trim(b.substr(c))
	}
	if (b === "") {
		return ""
	}
	return b + ";"
};
Clixpy.prototype.exec_function = function(a, b) {
	var c = this.last_event;
	if (b && a.indexOf("this") != -1) {
		a = a.replace(/([^a-z0-9]{1})this([\.\,\;\s\)])/igm, "$1inwhichobj$2")
	}
	;
	if (a.indexOf("return ") != -1) {
		var d = true;
		var f = function() {
		};
		var g = c;
		eval("tmpfunc = function(event, inwhichobj) { " + a + " };");
		d = f(c, b);
		if (d === undefined) {
			return true
		}
		return d
	} else {
		try {
			eval(a)
		} catch (e) {
		}
	}
};
Clixpy.prototype.get_time = function() {
	return new Date().getTime()
};
Clixpy.prototype.get_event = function(e) {
	if (!e && this.w.event) {
		e = this.w.event
	}
	return e
};
Clixpy.prototype.trim = function(a) {
	if (typeof (a) != "string") {
		return a
	}
	a = a.replace(/^\s+/, "");
	a = a.replace(/\s+$/, "");
	return a
};
Clixpy.prototype.get_screen_size = function() {
	var w = 0, h = 0;
	if (typeof (window.innerWidth) == 'number') {
		w = window.innerWidth;
		h = window.innerHeight
	} else if (document.documentElement
			&& (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight
	} else if (document.body
			&& (document.body.clientWidth || document.body.clientHeight)) {
		w = document.body.clientWidth;
		h = document.body.clientHeight
	} else {
		return false
	}
	return [ w, h ]
};
Clixpy.prototype.get_screen_scroll = function() {
	var x = 0, y = 0;
	if (typeof (this.w.pageYOffset) == 'number') {
		x = this.w.pageXOffset;
		y = this.w.pageYOffset
	} else if (this.d.documentElement
			&& (this.d.documentElement.scrollLeft || this.d.documentElement.scrollTop)) {
		y = this.d.documentElement.scrollTop;
		x = this.d.documentElement.scrollLeft
	} else if (this.d.body && (this.d.body.scrollTop !== undefined)) {
		x = this.d.body.scrollLeft;
		y = this.d.body.scrollTop
	} else {
		return false
	}
	return [ x, y ]
};
Clixpy.prototype.get_current_domain = function() {
	var a = this.w.location.href;
	a = a.replace(/^http(s)?\:\/\/?/i, "");
	a = a.replace(/^([^\/]+)\/.*/i, "$1");
	a = a.replace(/^([^\.]+\.){1,}([^\.]+\.[^\.]+)$/i, "$2");
	return a
};
Clixpy.prototype.get_cookie = function(a) {
	var c = this.d.cookie;
	c = c.split(";");
	for ( var i = 0; i < c.length; i++) {
		c[i] = this.trim(c[i]);
		c[i] = c[i].split("=");
		if (c[i][0] == a && c[i][1] !== undefined) {
			return unescape(c[i][1])
		}
	}
	return null
};
Clixpy.prototype.set_cookie = function(a, b, c) {
	if (!c) {
		c = "." + this.domain
	}
	this.d.cookie = a + "=" + b + "; path=/; domain=" + c + ";"
};
var clixpy_obj = new Clixpy();
clixpy_obj.INIT();
